package com.asset.troubleticket.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.asset.troubleticket.domain.TicketHistory;
@Repository
public class TicketHistoryDao {
	@Autowired
	SessionFactory sessionFactory;
	
	
	public void addTicketHistory(TicketHistory ticketHistory){
		try{
			sessionFactory.getCurrentSession().save(ticketHistory);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	
	public void editTicketHistory(TicketHistory ticketHistory){
		try{
			sessionFactory.getCurrentSession().saveOrUpdate(ticketHistory);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	public void deleteTicketHistory(TicketHistory ticketHistory){
		try{
			sessionFactory.getCurrentSession().delete(ticketHistory);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	public TicketHistory getById(Integer id){
		try{
		return (TicketHistory)	sessionFactory.getCurrentSession().load(TicketHistory.class,id);
			}catch(Exception ex){
				ex.printStackTrace();
				return null;
			}
	}
}
